﻿using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;

namespace MiniQQWebApi.Models.EF
{
    public partial class MiniQQ2020Context : DbContext
    {
        public MiniQQ2020Context()
        {
        }

        public MiniQQ2020Context(DbContextOptions<MiniQQ2020Context> options)
            : base(options)
        {
        }

        public virtual DbSet<T001用户表> T001用户表 { get; set; }
        public virtual DbSet<T002用户表> T002用户表 { get; set; }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            if (!optionsBuilder.IsConfigured)
            {
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. See http://go.microsoft.com/fwlink/?LinkId=723263 for guidance on storing connection strings.
                optionsBuilder.UseSqlServer("Server=.;Database=MiniQQ2020;Trusted_Connection=True;");
            }
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<T001用户表>(entity =>
            {
                entity.HasKey(e => e.Qq号);

                entity.Property(e => e.Qq号)
                    .HasColumnName("QQ号")
                    .HasMaxLength(50);

                entity.Property(e => e.密码)
                    .IsRequired()
                    .HasMaxLength(50);

                entity.Property(e => e.性别)
                    .IsRequired()
                    .HasMaxLength(1)
                    .IsFixedLength();

                entity.Property(e => e.昵称)
                    .IsRequired()
                    .HasMaxLength(50);

                entity.Property(e => e.生日).HasColumnType("date");

                entity.Property(e => e.邮箱)
                    .IsRequired()
                    .HasMaxLength(50);
            });

            modelBuilder.Entity<T002用户表>(entity =>
            {
                entity.HasNoKey();

                entity.Property(e => e.Qq号)
                    .IsRequired()
                    .HasColumnName("QQ号")
                    .HasMaxLength(50);

                entity.Property(e => e.密码)
                    .IsRequired()
                    .HasMaxLength(50);
            });

            OnModelCreatingPartial(modelBuilder);
        }

        partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
    }
}
